<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<html>
<head>
<title>商品维护</title>
<!-- 包含公共资源 -->
<%@ include file="/commons/metaf.jsp"%>
<%@ include file="/commons/meta-simpletable.jsp" %>
<script type="text/JavaScript">

	$(function() {
	});
	function buy(id) {
		$.post('<c:url value="/Shopping/buy.do"/>', {
			id : id
		}, function(data) {
			if (data.result) {
				$("<span style='color:red'>已成功加入购物车</span>")
						.insertBefore("#buyLink_"+id);
				$("<a href='${ctx}/Shopping/list.do'>查看购物车</a>").insertBefore("#buyLink_"+id);
				$("#buyLink_"+id).remove();
			}
		}, 'json');
	}
</script>
</head>
<body>
	<div id="container">
		<iframe id="header" src="${ctx }/pagesf/header.jsp" width="980"
			height="136" frameborder="0" scrolling="no"></iframe>
		<form action="${ctx }/Goods/list.do?flag=true&typeId=${query.typeId}" id="queryForm" method="post">
		
		<!-- 分页区域 -->
		<simpletable:pageToolbar page="${page}"></simpletable:pageToolbar>
		<!-- 分页区域 结束 -->
		<div class="catlist a_c">
			<ul class="w20p">
				<h3>商品图片</h3>
				<c:forEach items="${page.result }" var="goods">
					<li><a href="${ctx }/Goods/show.do?flag=true&id=${goods.id}"><img src="${goods.firstSmallPic }"/></a></li>
				</c:forEach>
			</ul>
			<ul class="w50p info">
				<h3>商品描述</h3>
				<c:forEach items="${page.result }" var="goods">
					
					<li><a href="${ctx }/Goods/show.do?flag=true&id=${goods.id}">${goods.descp }</a><br />
						<a href="javascript:;" id="buyLink_${goods.id}" onclick="buy(${goods.id})">加入购物车</a>
					</li>
				</c:forEach>
			</ul>
			<ul class="w10p price">
				<h3>价格</h3>
				<c:forEach items="${page.result }" var="goods">
					<li>一口价：<br />${goods.price }</li>
				</c:forEach>
			</ul>
		</div>
		
		
		<%-- 现在是第${query.pageNumber }页  <a href="${ctx }/Goods/list.do?flag=true&typeId=${query.typeId}&pageNumber=${query.pageNumber+1}">下一页</a> --%>
		<!-- 分页区域
		 -->
		<simpletable:pageToolbar page="${page}"></simpletable:pageToolbar>
		<!-- 分页区域 结束 -->
		</form>
		<iframe id="footer" src="${ctx }/pagesf/footer.jsp" width="980"
			height="150" frameborder="0" scrolling="no"></iframe>
	</div>
	<!--container end-->
</body>
</html>

